﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using Indeco.G24.Entities;
using Indeco.G24.Data;

#endregion

namespace Indeco.G24.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="DiaBanProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class DiaBanProviderBaseCore : EntityProviderBase<Indeco.G24.Entities.DiaBan, Indeco.G24.Entities.DiaBanKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByIDNhaCungCapFromNhaCungCapDiaBan
		
		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapDiaBan table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="iDNhaCungCap"></param>
		/// <returns>Returns a typed collection of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapDiaBan(System.Guid iDNhaCungCap)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapDiaBan(null,iDNhaCungCap, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapDiaBan table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDNhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapDiaBan(System.Guid iDNhaCungCap, int start, int pageLength)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapDiaBan(null, iDNhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapDiaBan table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapDiaBan(TransactionManager transactionManager, System.Guid iDNhaCungCap)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapDiaBan(transactionManager, iDNhaCungCap, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapDiaBan table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapDiaBan(TransactionManager transactionManager, System.Guid iDNhaCungCap,int start, int pageLength)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapDiaBan(transactionManager, iDNhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapDiaBan table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapDiaBan(System.Guid iDNhaCungCap,int start, int pageLength, out int count)
		{
			
			return GetByIDNhaCungCapFromNhaCungCapDiaBan(null, iDNhaCungCap, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapDiaBan table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDNhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public abstract TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapDiaBan(TransactionManager transactionManager,System.Guid iDNhaCungCap, int start, int pageLength, out int count);
		
		#endregion GetByIDNhaCungCapFromNhaCungCapDiaBan
		
		#region GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc
		
		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDNhaCungCap"></param>
		/// <returns>Returns a typed collection of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(System.Guid iDNhaCungCap)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(null,iDNhaCungCap, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDNhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(System.Guid iDNhaCungCap, int start, int pageLength)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(null, iDNhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDNhaCungCap)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(transactionManager, iDNhaCungCap, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDNhaCungCap,int start, int pageLength)
		{
			int count = -1;
			return GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(transactionManager, iDNhaCungCap, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDNhaCungCap"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(System.Guid iDNhaCungCap,int start, int pageLength, out int count)
		{
			
			return GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(null, iDNhaCungCap, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_NhaCungCap in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_NhaCungCap
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDNhaCungCap"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public abstract TList<DiaBan> GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager,System.Guid iDNhaCungCap, int start, int pageLength, out int count);
		
		#endregion GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc
		
		#region GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc
		
		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <returns>Returns a typed collection of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(System.Guid iDSanPhamDanhMuc)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(null,iDSanPhamDanhMuc, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.DiaBan objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(System.Guid iDSanPhamDanhMuc, int start, int pageLength)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(null, iDSanPhamDanhMuc, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDSanPhamDanhMuc)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(transactionManager, iDSanPhamDanhMuc, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager, System.Guid iDSanPhamDanhMuc,int start, int pageLength)
		{
			int count = -1;
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(transactionManager, iDSanPhamDanhMuc, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(System.Guid iDSanPhamDanhMuc,int start, int pageLength, out int count)
		{
			
			return GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(null, iDSanPhamDanhMuc, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_SanPhamDanhMuc in the
		///		tb_NhaCungCapSanPhamDanhMuc table. Table tb_DiaBan is related to table tb_SanPhamDanhMuc
		///		through the (M:N) relationship defined in the tb_NhaCungCapSanPhamDanhMuc table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDSanPhamDanhMuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public abstract TList<DiaBan> GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc(TransactionManager transactionManager,System.Guid iDSanPhamDanhMuc, int start, int pageLength, out int count);
		
		#endregion GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc
		
		#region GetByIDNguoiDungFromNguoiDungDiaBan
		
		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungDiaBan table. Table tb_DiaBan is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungDiaBan table.
		/// </summary>
		/// <param name="iDNguoiDung"></param>
		/// <returns>Returns a typed collection of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNguoiDungFromNguoiDungDiaBan(System.Guid iDNguoiDung)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungDiaBan(null,iDNguoiDung, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets Indeco.G24.Entities.DiaBan objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungDiaBan table. Table tb_DiaBan is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungDiaBan table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDNguoiDung"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNguoiDungFromNguoiDungDiaBan(System.Guid iDNguoiDung, int start, int pageLength)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungDiaBan(null, iDNguoiDung, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungDiaBan table. Table tb_DiaBan is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNguoiDung"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNguoiDungFromNguoiDungDiaBan(TransactionManager transactionManager, System.Guid iDNguoiDung)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungDiaBan(transactionManager, iDNguoiDung, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungDiaBan table. Table tb_DiaBan is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDNguoiDung"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNguoiDungFromNguoiDungDiaBan(TransactionManager transactionManager, System.Guid iDNguoiDung,int start, int pageLength)
		{
			int count = -1;
			return GetByIDNguoiDungFromNguoiDungDiaBan(transactionManager, iDNguoiDung, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets DiaBan objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungDiaBan table. Table tb_DiaBan is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungDiaBan table.
		/// </summary>
		/// <param name="iDNguoiDung"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of tb_DiaBan objects.</returns>
		public TList<DiaBan> GetByIDNguoiDungFromNguoiDungDiaBan(System.Guid iDNguoiDung,int start, int pageLength, out int count)
		{
			
			return GetByIDNguoiDungFromNguoiDungDiaBan(null, iDNguoiDung, start, pageLength, out count);
		}


		/// <summary>
		///		Gets tb_DiaBan objects from the datasource by ID_NguoiDung in the
		///		tb_NguoiDungDiaBan table. Table tb_DiaBan is related to table tb_NguoiDung
		///		through the (M:N) relationship defined in the tb_NguoiDungDiaBan table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="iDNguoiDung"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of DiaBan objects.</returns>
		public abstract TList<DiaBan> GetByIDNguoiDungFromNguoiDungDiaBan(TransactionManager transactionManager,System.Guid iDNguoiDung, int start, int pageLength, out int count);
		
		#endregion GetByIDNguoiDungFromNguoiDungDiaBan
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, Indeco.G24.Entities.DiaBanKey key)
		{
			return Delete(transactionManager, key.IDDiaBan);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="iDDiaBan">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Guid iDDiaBan)
		{
			return Delete(null, iDDiaBan);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Guid iDDiaBan);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override Indeco.G24.Entities.DiaBan Get(TransactionManager transactionManager, Indeco.G24.Entities.DiaBanKey key, int start, int pageLength)
		{
			return GetByIDDiaBan(transactionManager, key.IDDiaBan, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_tb_DiaBan index.
		/// </summary>
		/// <param name="iDDiaBan"></param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.DiaBan"/> class.</returns>
		public Indeco.G24.Entities.DiaBan GetByIDDiaBan(System.Guid iDDiaBan)
		{
			int count = -1;
			return GetByIDDiaBan(null,iDDiaBan, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_DiaBan index.
		/// </summary>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.DiaBan"/> class.</returns>
		public Indeco.G24.Entities.DiaBan GetByIDDiaBan(System.Guid iDDiaBan, int start, int pageLength)
		{
			int count = -1;
			return GetByIDDiaBan(null, iDDiaBan, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_DiaBan index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.DiaBan"/> class.</returns>
		public Indeco.G24.Entities.DiaBan GetByIDDiaBan(TransactionManager transactionManager, System.Guid iDDiaBan)
		{
			int count = -1;
			return GetByIDDiaBan(transactionManager, iDDiaBan, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_DiaBan index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.DiaBan"/> class.</returns>
		public Indeco.G24.Entities.DiaBan GetByIDDiaBan(TransactionManager transactionManager, System.Guid iDDiaBan, int start, int pageLength)
		{
			int count = -1;
			return GetByIDDiaBan(transactionManager, iDDiaBan, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_DiaBan index.
		/// </summary>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.DiaBan"/> class.</returns>
		public Indeco.G24.Entities.DiaBan GetByIDDiaBan(System.Guid iDDiaBan, int start, int pageLength, out int count)
		{
			return GetByIDDiaBan(null, iDDiaBan, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_DiaBan index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDDiaBan"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.DiaBan"/> class.</returns>
		public abstract Indeco.G24.Entities.DiaBan GetByIDDiaBan(TransactionManager transactionManager, System.Guid iDDiaBan, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a Indeco.G24.Entities.TList&lt;DiaBan&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="Indeco.G24.Entities.TList&lt;DiaBan&gt;"/></returns>
		public static Indeco.G24.Entities.TList<DiaBan> Fill(IDataReader reader, Indeco.G24.Entities.TList<DiaBan> rows, int start, int pageLength)
		{
		// advance to the starting row
		for (int i = 0; i < start; i++)
		{
			if (!reader.Read())
			return rows; // not enough rows, just return
		}
		for (int i = 0; i < pageLength; i++)
		{
			if (!reader.Read())
			break; // we are done
			string key = null;
			
			Indeco.G24.Entities.DiaBan c = null;
			if (DataRepository.Provider.UseEntityFactory)
			{
			key = new System.Text.StringBuilder("DiaBan")
			.Append("|").Append((reader.IsDBNull(((int)Indeco.G24.Entities.DiaBanColumn.IDDiaBan - 1))?Guid.NewGuid():(System.Guid)reader[((int)Indeco.G24.Entities.DiaBanColumn.IDDiaBan - 1)]).ToString()).ToString();
			c = EntityManager.LocateOrCreate<DiaBan>(
			key.ToString(), // EntityTrackingKey
			"DiaBan",  //Creational Type
			DataRepository.Provider.EntityCreationalFactoryType,  //Factory used to create entity
			DataRepository.Provider.EnableEntityTracking); // Track this entity?
			}
			else
			{
			c = new Indeco.G24.Entities.DiaBan();
			}
			
			if (!DataRepository.Provider.EnableEntityTracking ||
			c.EntityState == EntityState.Added ||
			(DataRepository.Provider.EnableEntityTracking &&
			((DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
			(DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.DiscardChanges && (c.EntityState == EntityState.Unchanged ||
								c.EntityState == EntityState.Changed)))))
						{
			c.SuppressEntityEvents = true;
			c.IDDiaBan = (System.Guid)reader["ID_DiaBan"];
			c.OriginalIDDiaBan = c.IDDiaBan;
			c.IDDiaBanCha = (System.Guid)reader["ID_DiaBanCha"];
			c.MaDiaBan = (System.String)reader["MaDiaBan"];
			c.Ten = (System.String)reader["Ten"];
			c.Mota = reader.IsDBNull(reader.GetOrdinal("Mota")) ? null : (System.String)reader["Mota"];
			c.HinhMinhHoa = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoa")) ? null : (System.String)reader["HinhMinhHoa"];
			c.MaVung = reader.IsDBNull(reader.GetOrdinal("MaVung")) ? null : (System.String)reader["MaVung"];
			c.MacDinh = (System.Boolean)reader["MacDinh"];
			c.TrangThai = (System.Boolean)reader["TrangThai"];
			c.EntityTrackingKey = key;
			c.AcceptChanges();
			c.SuppressEntityEvents = false;
			}
			rows.Add(c);
		}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="Indeco.G24.Entities.DiaBan"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.DiaBan"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, Indeco.G24.Entities.DiaBan entity)
		{
			if (!reader.Read()) return;
			
			entity.IDDiaBan = (System.Guid)reader["ID_DiaBan"];
			entity.OriginalIDDiaBan = (System.Guid)reader["ID_DiaBan"];
			entity.IDDiaBanCha = (System.Guid)reader["ID_DiaBanCha"];
			entity.MaDiaBan = (System.String)reader["MaDiaBan"];
			entity.Ten = (System.String)reader["Ten"];
			entity.Mota = reader.IsDBNull(reader.GetOrdinal("Mota")) ? null : (System.String)reader["Mota"];
			entity.HinhMinhHoa = reader.IsDBNull(reader.GetOrdinal("HinhMinhHoa")) ? null : (System.String)reader["HinhMinhHoa"];
			entity.MaVung = reader.IsDBNull(reader.GetOrdinal("MaVung")) ? null : (System.String)reader["MaVung"];
			entity.MacDinh = (System.Boolean)reader["MacDinh"];
			entity.TrangThai = (System.Boolean)reader["TrangThai"];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="Indeco.G24.Entities.DiaBan"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.DiaBan"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, Indeco.G24.Entities.DiaBan entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IDDiaBan = (System.Guid)dataRow["ID_DiaBan"];
			entity.OriginalIDDiaBan = (System.Guid)dataRow["ID_DiaBan"];
			entity.IDDiaBanCha = (System.Guid)dataRow["ID_DiaBanCha"];
			entity.MaDiaBan = (System.String)dataRow["MaDiaBan"];
			entity.Ten = (System.String)dataRow["Ten"];
			entity.Mota = Convert.IsDBNull(dataRow["Mota"]) ? null : (System.String)dataRow["Mota"];
			entity.HinhMinhHoa = Convert.IsDBNull(dataRow["HinhMinhHoa"]) ? null : (System.String)dataRow["HinhMinhHoa"];
			entity.MaVung = Convert.IsDBNull(dataRow["MaVung"]) ? null : (System.String)dataRow["MaVung"];
			entity.MacDinh = (System.Boolean)dataRow["MacDinh"];
			entity.TrangThai = (System.Boolean)dataRow["TrangThai"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.DiaBan"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">Indeco.G24.Entities.DiaBan Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		internal override void DeepLoad(TransactionManager transactionManager, Indeco.G24.Entities.DiaBan entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByIDDiaBan methods when available
			
			#region NhaCungCapSanPhamDanhMucCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NhaCungCapSanPhamDanhMuc>|NhaCungCapSanPhamDanhMucCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapSanPhamDanhMucCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NhaCungCapSanPhamDanhMucCollection = DataRepository.NhaCungCapSanPhamDanhMucProvider.GetByIDDiaBan(transactionManager, entity.IDDiaBan);

				if (deep && entity.NhaCungCapSanPhamDanhMucCollection.Count > 0)
				{
					deepHandles.Add("NhaCungCapSanPhamDanhMucCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NhaCungCapSanPhamDanhMuc>) DataRepository.NhaCungCapSanPhamDanhMucProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapSanPhamDanhMucCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NhaCungCapCollection_From_NhaCungCapDiaBan
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<NhaCungCap>|NhaCungCapCollection_From_NhaCungCapDiaBan", deepLoadType, innerList))
			{
				entity.NhaCungCapCollection_From_NhaCungCapDiaBan = DataRepository.NhaCungCapProvider.GetByIDDiaBanFromNhaCungCapDiaBan(transactionManager, entity.IDDiaBan);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapCollection_From_NhaCungCapDiaBan' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NhaCungCapCollection_From_NhaCungCapDiaBan != null)
				{
					deepHandles.Add("NhaCungCapCollection_From_NhaCungCapDiaBan",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< NhaCungCap >) DataRepository.NhaCungCapProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapCollection_From_NhaCungCapDiaBan, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<NhaCungCap>|NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc", deepLoadType, innerList))
			{
				entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc = DataRepository.NhaCungCapProvider.GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(transactionManager, entity.IDDiaBan);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc != null)
				{
					deepHandles.Add("NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< NhaCungCap >) DataRepository.NhaCungCapProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NguoiDungCollection_From_NguoiDungDiaBan
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<NguoiDung>|NguoiDungCollection_From_NguoiDungDiaBan", deepLoadType, innerList))
			{
				entity.NguoiDungCollection_From_NguoiDungDiaBan = DataRepository.NguoiDungProvider.GetByIDDiaBanFromNguoiDungDiaBan(transactionManager, entity.IDDiaBan);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NguoiDungCollection_From_NguoiDungDiaBan' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NguoiDungCollection_From_NguoiDungDiaBan != null)
				{
					deepHandles.Add("NguoiDungCollection_From_NguoiDungDiaBan",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< NguoiDung >) DataRepository.NguoiDungProvider.DeepLoad,
						new object[] { transactionManager, entity.NguoiDungCollection_From_NguoiDungDiaBan, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<SanPhamDanhMuc>|SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc", deepLoadType, innerList))
			{
				entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc = DataRepository.SanPhamDanhMucProvider.GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc(transactionManager, entity.IDDiaBan);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc != null)
				{
					deepHandles.Add("SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< SanPhamDanhMuc >) DataRepository.SanPhamDanhMucProvider.DeepLoad,
						new object[] { transactionManager, entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region BangGiaSanPhamCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<BangGiaSanPham>|BangGiaSanPhamCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'BangGiaSanPhamCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.BangGiaSanPhamCollection = DataRepository.BangGiaSanPhamProvider.GetByIDDiaBan(transactionManager, entity.IDDiaBan);

				if (deep && entity.BangGiaSanPhamCollection.Count > 0)
				{
					deepHandles.Add("BangGiaSanPhamCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<BangGiaSanPham>) DataRepository.BangGiaSanPhamProvider.DeepLoad,
						new object[] { transactionManager, entity.BangGiaSanPhamCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NhaCungCapDiaBanCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NhaCungCapDiaBan>|NhaCungCapDiaBanCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NhaCungCapDiaBanCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NhaCungCapDiaBanCollection = DataRepository.NhaCungCapDiaBanProvider.GetByIDDiaBan(transactionManager, entity.IDDiaBan);

				if (deep && entity.NhaCungCapDiaBanCollection.Count > 0)
				{
					deepHandles.Add("NhaCungCapDiaBanCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NhaCungCapDiaBan>) DataRepository.NhaCungCapDiaBanProvider.DeepLoad,
						new object[] { transactionManager, entity.NhaCungCapDiaBanCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NguoiDungDiaBanCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NguoiDungDiaBan>|NguoiDungDiaBanCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NguoiDungDiaBanCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NguoiDungDiaBanCollection = DataRepository.NguoiDungDiaBanProvider.GetByIDDiaBan(transactionManager, entity.IDDiaBan);

				if (deep && entity.NguoiDungDiaBanCollection.Count > 0)
				{
					deepHandles.Add("NguoiDungDiaBanCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NguoiDungDiaBan>) DataRepository.NguoiDungDiaBanProvider.DeepLoad,
						new object[] { transactionManager, entity.NguoiDungDiaBanCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the Indeco.G24.Entities.DiaBan object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">Indeco.G24.Entities.DiaBan instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">Indeco.G24.Entities.DiaBan Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		internal override bool DeepSave(TransactionManager transactionManager, Indeco.G24.Entities.DiaBan entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<Delegate, object> deepHandles = new Dictionary<Delegate, object>();

			#region NhaCungCapCollection_From_NhaCungCapDiaBan>
			if (CanDeepSave(entity.NhaCungCapCollection_From_NhaCungCapDiaBan, "List<NhaCungCap>|NhaCungCapCollection_From_NhaCungCapDiaBan", deepSaveType, innerList))
			{
				if (entity.NhaCungCapCollection_From_NhaCungCapDiaBan.Count > 0 || entity.NhaCungCapCollection_From_NhaCungCapDiaBan.DeletedItems.Count > 0)
				{
					DataRepository.NhaCungCapProvider.Save(transactionManager, entity.NhaCungCapCollection_From_NhaCungCapDiaBan); 
					deepHandles.Add(
						(DeepSaveHandle<NhaCungCap>) DataRepository.NhaCungCapProvider.DeepSave,
						new object[] { transactionManager, entity.NhaCungCapCollection_From_NhaCungCapDiaBan, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 

			#region NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc>
			if (CanDeepSave(entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc, "List<NhaCungCap>|NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc", deepSaveType, innerList))
			{
				if (entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc.Count > 0 || entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc.DeletedItems.Count > 0)
				{
					DataRepository.NhaCungCapProvider.Save(transactionManager, entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc); 
					deepHandles.Add(
						(DeepSaveHandle<NhaCungCap>) DataRepository.NhaCungCapProvider.DeepSave,
						new object[] { transactionManager, entity.NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 

			#region NguoiDungCollection_From_NguoiDungDiaBan>
			if (CanDeepSave(entity.NguoiDungCollection_From_NguoiDungDiaBan, "List<NguoiDung>|NguoiDungCollection_From_NguoiDungDiaBan", deepSaveType, innerList))
			{
				if (entity.NguoiDungCollection_From_NguoiDungDiaBan.Count > 0 || entity.NguoiDungCollection_From_NguoiDungDiaBan.DeletedItems.Count > 0)
				{
					DataRepository.NguoiDungProvider.Save(transactionManager, entity.NguoiDungCollection_From_NguoiDungDiaBan); 
					deepHandles.Add(
						(DeepSaveHandle<NguoiDung>) DataRepository.NguoiDungProvider.DeepSave,
						new object[] { transactionManager, entity.NguoiDungCollection_From_NguoiDungDiaBan, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 

			#region SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc>
			if (CanDeepSave(entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc, "List<SanPhamDanhMuc>|SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc", deepSaveType, innerList))
			{
				if (entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc.Count > 0 || entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc.DeletedItems.Count > 0)
				{
					DataRepository.SanPhamDanhMucProvider.Save(transactionManager, entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc); 
					deepHandles.Add(
						(DeepSaveHandle<SanPhamDanhMuc>) DataRepository.SanPhamDanhMucProvider.DeepSave,
						new object[] { transactionManager, entity.SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc, deepSaveType, childTypes, innerList }
					);
				}
			}
			#endregion 
	
			#region List<NhaCungCapSanPhamDanhMuc>
				if (CanDeepSave(entity.NhaCungCapSanPhamDanhMucCollection, "List<NhaCungCapSanPhamDanhMuc>|NhaCungCapSanPhamDanhMucCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NhaCungCapSanPhamDanhMuc child in entity.NhaCungCapSanPhamDanhMucCollection)
					{
						if(child.IDDiaBanSource != null)
							child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;
						else
							child.IDDiaBan = entity.IDDiaBan;

						//Handle right table of NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc
						if(child.IDDiaBanSource != null)
						{
								child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;

						}

						//Handle right table of NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc
						if(child.IDNhaCungCapSource != null)
						{
								child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;

						}

						//Handle right table of NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc
						if(child.IDSanPhamDanhMucSource != null)
						{
								child.IDSanPhamDanhMuc = child.IDSanPhamDanhMucSource.IDSanPhamDanhMuc;

						}

					}

					if (entity.NhaCungCapSanPhamDanhMucCollection.Count > 0 || entity.NhaCungCapSanPhamDanhMucCollection.DeletedItems.Count > 0)
					{
						DataRepository.NhaCungCapSanPhamDanhMucProvider.Save(transactionManager, entity.NhaCungCapSanPhamDanhMucCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NhaCungCapSanPhamDanhMuc >) DataRepository.NhaCungCapSanPhamDanhMucProvider.DeepSave,
							new object[] { transactionManager, entity.NhaCungCapSanPhamDanhMucCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<BangGiaSanPham>
				if (CanDeepSave(entity.BangGiaSanPhamCollection, "List<BangGiaSanPham>|BangGiaSanPhamCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(BangGiaSanPham child in entity.BangGiaSanPhamCollection)
					{
						if(child.IDDiaBanSource != null)
							child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;
						else
							child.IDDiaBan = entity.IDDiaBan;

					}

					if (entity.BangGiaSanPhamCollection.Count > 0 || entity.BangGiaSanPhamCollection.DeletedItems.Count > 0)
					{
						DataRepository.BangGiaSanPhamProvider.Save(transactionManager, entity.BangGiaSanPhamCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< BangGiaSanPham >) DataRepository.BangGiaSanPhamProvider.DeepSave,
							new object[] { transactionManager, entity.BangGiaSanPhamCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<NhaCungCapDiaBan>
				if (CanDeepSave(entity.NhaCungCapDiaBanCollection, "List<NhaCungCapDiaBan>|NhaCungCapDiaBanCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NhaCungCapDiaBan child in entity.NhaCungCapDiaBanCollection)
					{
						if(child.IDDiaBanSource != null)
							child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;
						else
							child.IDDiaBan = entity.IDDiaBan;

						//Handle right table of NhaCungCapCollection_From_NhaCungCapDiaBan
						if(child.IDDiaBanSource != null)
						{
								child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;

						}

						//Handle right table of NhaCungCapCollection_From_NhaCungCapDiaBan
						if(child.IDNhaCungCapSource != null)
						{
								child.IDNhaCungCap = child.IDNhaCungCapSource.IDNhaCungCap;

						}

					}

					if (entity.NhaCungCapDiaBanCollection.Count > 0 || entity.NhaCungCapDiaBanCollection.DeletedItems.Count > 0)
					{
						DataRepository.NhaCungCapDiaBanProvider.Save(transactionManager, entity.NhaCungCapDiaBanCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NhaCungCapDiaBan >) DataRepository.NhaCungCapDiaBanProvider.DeepSave,
							new object[] { transactionManager, entity.NhaCungCapDiaBanCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
	
			#region List<NguoiDungDiaBan>
				if (CanDeepSave(entity.NguoiDungDiaBanCollection, "List<NguoiDungDiaBan>|NguoiDungDiaBanCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NguoiDungDiaBan child in entity.NguoiDungDiaBanCollection)
					{
						if(child.IDDiaBanSource != null)
							child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;
						else
							child.IDDiaBan = entity.IDDiaBan;

						//Handle right table of NguoiDungCollection_From_NguoiDungDiaBan
						if(child.IDDiaBanSource != null)
						{
								child.IDDiaBan = child.IDDiaBanSource.IDDiaBan;

						}

						//Handle right table of NguoiDungCollection_From_NguoiDungDiaBan
						if(child.IDNguoiDungSource != null)
						{
								child.IDNguoiDung = child.IDNguoiDungSource.IDNguoiDung;

						}

					}

					if (entity.NguoiDungDiaBanCollection.Count > 0 || entity.NguoiDungDiaBanCollection.DeletedItems.Count > 0)
					{
						DataRepository.NguoiDungDiaBanProvider.Save(transactionManager, entity.NguoiDungDiaBanCollection);
						
						deepHandles.Add(
							(DeepSaveHandle< NguoiDungDiaBan >) DataRepository.NguoiDungDiaBanProvider.DeepSave,
							new object[] { transactionManager, entity.NguoiDungDiaBanCollection, deepSaveType, childTypes, innerList }
						);
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region DiaBanChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>Indeco.G24.Entities.DiaBan</c>
	///</summary>
	public enum DiaBanChildEntityTypes
	{

		///<summary>
		/// Collection of <c>DiaBan</c> as OneToMany for NhaCungCapSanPhamDanhMucCollection
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCapSanPhamDanhMuc>))]
		NhaCungCapSanPhamDanhMucCollection,

		///<summary>
		/// Collection of <c>DiaBan</c> as ManyToMany for NhaCungCapCollection_From_NhaCungCapDiaBan
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCap>))]
		NhaCungCapCollection_From_NhaCungCapDiaBan,

		///<summary>
		/// Collection of <c>DiaBan</c> as ManyToMany for NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCap>))]
		NhaCungCapCollection_From_NhaCungCapSanPhamDanhMuc,

		///<summary>
		/// Collection of <c>DiaBan</c> as ManyToMany for NguoiDungCollection_From_NguoiDungDiaBan
		///</summary>
		[ChildEntityType(typeof(TList<NguoiDung>))]
		NguoiDungCollection_From_NguoiDungDiaBan,

		///<summary>
		/// Collection of <c>DiaBan</c> as ManyToMany for SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc
		///</summary>
		[ChildEntityType(typeof(TList<SanPhamDanhMuc>))]
		SanPhamDanhMucCollection_From_NhaCungCapSanPhamDanhMuc,

		///<summary>
		/// Collection of <c>DiaBan</c> as OneToMany for BangGiaSanPhamCollection
		///</summary>
		[ChildEntityType(typeof(TList<BangGiaSanPham>))]
		BangGiaSanPhamCollection,

		///<summary>
		/// Collection of <c>DiaBan</c> as OneToMany for NhaCungCapDiaBanCollection
		///</summary>
		[ChildEntityType(typeof(TList<NhaCungCapDiaBan>))]
		NhaCungCapDiaBanCollection,

		///<summary>
		/// Collection of <c>DiaBan</c> as OneToMany for NguoiDungDiaBanCollection
		///</summary>
		[ChildEntityType(typeof(TList<NguoiDungDiaBan>))]
		NguoiDungDiaBanCollection,
	}
	
	#endregion DiaBanChildEntityTypes
	
	#region DiaBanFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;DiaBanColumn&gt;"/> class
	/// that is used exclusively with a <see cref="DiaBan"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class DiaBanFilterBuilder : SqlFilterBuilder<DiaBanColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the DiaBanFilterBuilder class.
		/// </summary>
		public DiaBanFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the DiaBanFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public DiaBanFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the DiaBanFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public DiaBanFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion DiaBanFilterBuilder
	
	#region DiaBanParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;DiaBanColumn&gt;"/> class
	/// that is used exclusively with a <see cref="DiaBan"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class DiaBanParameterBuilder : ParameterizedSqlFilterBuilder<DiaBanColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the DiaBanParameterBuilder class.
		/// </summary>
		public DiaBanParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the DiaBanParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public DiaBanParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the DiaBanParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public DiaBanParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion DiaBanParameterBuilder
} // end namespace
